/*
 * @Author: szx
 * @Date: 2022-04-19 18:40:57
 * @LastEditTime: 2022-04-19 18:47:00
 * @Description:
 * @FilePath: \leetcode\剑指offerII\069\069.js
 */
/**
 * @param {number[]} arr
 * @return {number}
 */
 var peakIndexInMountainArray = function (arr) {
    let l = 1,
        r = arr.length - 2;
    while (l <= r) {
        const mid = ((r - l) >> 1) + l;
        if (arr[mid] > arr[mid - 1] && arr[mid] > arr[mid + 1]) return mid;
        else if (arr[mid] > arr[mid - 1]) l = mid + 1;
        else r = mid - 1;
    }
    return l;
};
